import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import { resolve } from 'path';
/**
 * 网络请求代理对象
 */
const proxyObj = {
  '/api': {
    target: 'http://localhost:21812',
    //  target: 'http://1.92.143.154:21812',
    changeOrigin: true,
    rewrite: (path) => path.replace(/^\/api/, '')
  }
}


// https://vite.dev/config/
export default defineConfig({
  plugins: [react(), nodePolyfills()],

  server: {
    port: 8081,
    proxy: proxyObj
  },

  resolve: {
    alias: {
      '@': resolve(__dirname, 'src'),
      'comp': resolve(__dirname, 'src/components'),
      'api': resolve(__dirname, 'src/network'),
      'utils': resolve(__dirname, 'src/utils'),
      'hooks': resolve(__dirname, 'src/hooks'),
    }
  }

})
